'use strict'

const fs = require('fs')

console.log('favicon.js start ...')

exports.favicon = (dir,response) => {
    if(!fs.existsSync(dir)) return
    fs.readFile(dir, function (err, data) {
        if (err) {
            console.log('err message = ', err.message)
            response.statusCode = 404
            response.end()
        } else {
            response.writeHead(200, { 'Content-Type': 'image/x-icon' })
            response.write(data)
            response.end()
        }

    })
}
